﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HarmonnySearch
{
    public static class Extensions
    {
        public static void SortDescending(this List<HSParticle> list)
        {
            list.Sort(delegate(HSParticle p1, HSParticle p2)
            {
                return p1.Fitness.CompareTo(p2.Fitness);
            });
            list.Reverse();
        }

        public static void SortAscending(this List<HSParticle> list)
        {
            list.Sort(delegate(HSParticle p1, HSParticle p2)
            {
                return p1.Fitness.CompareTo(p2.Fitness);
            });
        }


        public static List<byte> CreateList(int listSize, int minValue, int maxValue)
        {
            byte[] list = new byte[listSize];

            int value = new Random().Next(minValue, maxValue);

            for (int i = 0; i < value; i++)
                list[i] = 1;

            return list.ToList();
        }
    }
}
